<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@include file="../../include/taglib.jsp"%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<%@include file="../../include/inhead.jsp"%>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"
	href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">

<!-- 可选的Bootstrap主题文件（一般不用引入） -->
<link rel="stylesheet"
	href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<title>车型选择-- E爱车</title>
<%@include file="../../include/iswechat.jsp" %>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
			<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
			<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
	
<style>
body {
	color: #444;;
	background-color: #eee;
}

a {
	text-decoration: none
}

ul {
	padding: 0px;
	margin: 0px;
}

.navbar-eaiche {
	background-color: #fff;
	border-bottom: 1px solid #ccc;
}

.tile {
	border: 1px solid #ccc;
	background-color: #fff;
	height: 150px;
	line-height: 150px;
	margin-top: 20px;
	text-align: center;
	padding: 0px;
	border-radius: 5px;
}

.tile img {
	width: 40%;
}

/*********************车型选择列表*********************/
.car-title {
	background-color: #ccc;
	border: 1px solid #ccc;
	height: 30px;
	line-height: 30px;
	font-weight: bold;
	padding-left: 10px;
}

.car-list {
	height: 70px;
	line-height: 70px;
	border-bottom: 1px solid #ccc;
	background-color: #fff;
	padding-left: 10px;
}

.car-list img {
	border: 1px solid #eee;
	margin-right: 10px;
}

.sub-car-box {
	position: fixed;
	left: 200px;
	right: 0px;
	top: 0px;
	background-color: #fff;
	height: 100%;
	display: none;
	border-left: 3px solid #bbb;
}

.sub-car-box li {
	height: 40px;
	line-height: 40px;
	padding-left: 5px;
	list-style: none;
	border-bottom: 1px solid #ccc;
}

.sub-model {
	display: none;
}

.sub-model li {
	height: 30px;
	line-height: 30px;
	color: red;
	padding-left: 15px;
	list-style: none;
	border-bottom: 1px solid #ccc;
}

.char-list {
	width: 50px;
	position: fixed;
	right: 0px;
	top: 0px;
	background-color: #eee;
	border-left: 1px solid #ccc;
	padding-left: 15px;
	height: 100%;
	z-index: 10000;
}

.char-list span {
	display: block;
	width: 30px;
	height: 30px;
	font-size: 18px;
	font-weight: bold;
}
/*********************车型选择列表*********************/
</style>
</head>
<body>
	<!-- 功能块开始 -->
	<div class="container-fluid">
		<div class="row" id="list"></div>
	</div>
	<div class="char-list">
		<span><a href="#A">A</a></span> <span><a href="#B">B</a></span> <span><a
			href="#C">C</a></span> <span><a href="#D">D</a></span> <span><a
			href="#E">E</a></span> <span><a href="#F">F</a></span> <span><a
			href="#G">G</a></span> <span><a href="#H">H</a></span> <span><a
			href="#I">I</a></span>
	</div>
	<div class="sub-car-box">
		<ul id="sublist">

		</ul>
	</div>
	<!-- 功能块结束 -->
	<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
	<script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script
		src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
	<script>
		$(function() {
			var a = [ "A", "B" ];

			var strhtml = "";
			$
					.post(
							"${ctx}/weixin/f/matenance/by/brand/list",
							function(data) {
								if (data.success) {
									for (var i = 0; i < a.length; i++) {
										for (var j = 0; j < data.rows.length; j++) {
											if (a[i] == data.rows[j].letter) {
												if (strhtml
														.indexOf('<div class="car-title"><a name="'+a[i]+'">'
																+ a[i]
																+ '</a></div>') == -1) {

													strhtml += '<div class="car-title"><a name="'+a[i]+'">'
															+ a[i]
															+ '</a></div>';
													strhtml += '<div class="car-list" onclick="fincilik(this,\''
															+ data.rows[j].brandId
															+ '\');"><img src="${ctx }/static/images/brand/'+data.rows[j].images+'.jpg" style="width:50px;"/>'
															+ data.rows[j].brandname
															+ '</div>';
												} else {

													strhtml += '<div class="car-list" onclick="fincilik(this,\''
															+ data.rows[j].brandId
															+ '\');"><img src="${ctx }/static/images/brand/'+data.rows[j].images+'.jpg" style="width:50px;"/>'
															+ data.rows[j].brandname
															+ '</div>';
												}
											}
										}
									}
									$('#list').html(strhtml);

								}
							});
		});

		function fincilik(car, id) {

			var sthtml = "";
			$
					.post(
							"${ctx}/weixin/f/matenance/by/brand/list",
							{
								id : id
							},
							function(data) {
								if (data.success) {
									if (data.rows != null
											&& data.rows.length > 0) {
										for (var k = 0; k < data.rows.length; k++) {
											if (data.rows[k].pid == id) {
												sthtml += "<li onclick=\"ziclick(this,'"
														+ data.rows[k].brandId
														+ "');\">"
														+ data.rows[k].brandname
														+ "</li>";
												sthtml += "<ul class=\"sub-model\" id=\"submodel"+data.rows[k].brandId+"\">";

												sthtml += "</ul>";
											}
										}
									} else {
										sthtml += "<li>暂无数据</li>";
									}
								}
								$("#sublist").html(sthtml);
							}, "json");

			$('.sub-car-box').show();
			$(car).css('border-left', '3px solid red');
			$(car).siblings().css('border-left', '0px');

		}

		function ziclick(model, id) {
			var uhtml = "";
			$.post("${ctx}/weixin/f/matenance/by/brand/list", {
				id : id
			}, function(data) {
				if (data.success) {
					if (data.rows != null && data.rows.length) {
						for (var k = 0; k < data.rows.length; k++) {
							uhtml += "<li onclick=\"setcokie('"+data.rows[k].brandId+"');\">" + data.rows[k].brandname + "</li>";
						}
					}else{
						uhtml+="<li>暂无数据</li>";
					}

				}
				$("#submodel" + id).html(uhtml);
			}, "json");
			$(model).parent().find('.sub-model').hide();
			$(model).next().css('display', 'block');
			$(model).siblings().css('background-color', '#fff').css(
					'border-left', '0px');
			$(model).css('background-color', '#FFFFCC').css('border-left',
					'2px solid red');
		}
		
		function setcokie(id){
			$.post("${ctx}/weixin/f/matenance/by/brand/setbrandbyid",
					{id:id},
					function(data){
						if(data.success){
							window.location.href="${ctx}"+data.url;
						}else{
							alert(data.message);
						}
					},"json");
		}
	</script>
</body>
</html>

